from recbole.model.general_recommender import BPR
from recbole.quick_start import load_data_and_model
from sklearn.manifold import TSNE
from sklearn.datasets import load_iris
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
from sklearn.neighbors import KernelDensity

if __name__ == '__main__':
    config, model, dataset, train_data, valid_data, test_data = load_data_and_model(
        model_file='saved/DGCF-Dec-25-2023_00-05-20.pth',
    )
    bpr: BPR = model
    tsne = TSNE(2, verbose=1)
    tsne_proj = tsne.fit_transform(bpr.item_embedding.weight.detach().numpy())
    kde = KernelDensity(bandwidth=0.5, kernel='gaussian')
    kde.fit(tsne_proj)
    plt.scatter(tsne_proj[:, 0], tsne_proj[:, 1])
    plt.colorbar()
    plt.show()
